package org.example.chapter3_3.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Insert;
import org.example.chapter3_3.entity.Student;

import java.util.List;

@Mapper
public interface StudentDao {
    @Select("select * from students where id = #{id}")
    Student findById(int id);

    @Insert("INSERT INTO students(name, age, sex) VALUES(#{name}, #{age}, #{sex})")
    int insert(Student student);

    @Update("UPDATE students SET name=#{name}, age=#{age}, sex=#{sex} WHERE id=#{id}")
    int update(Student student);

    @Delete("DELETE FROM students WHERE id = #{id}")
    int deleteById(int id);
}